using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Text;
//
using Alogient.Cameleon.Sdk;

namespace Alogient.Cameleon.Forms.Sdk.Items
{
    public enum FormStatus
    {
        New,
        Pending,
        Approved
    }

    public enum FormDisplayType
    {
        LabelLeft,
        LabelOver
    }

    public class Form
    {
        #region Properties

        public int ID { get; protected set; }
        public string Name { get; protected set; }
        public string CultureCode { get; protected set; }
        public DateTime CreationDate { get; protected set; }
        public DateTime LastModifiedDate { get; protected set; }
        public DateTime ApprobationDate { get; protected set; }
        public FormStatus Status { get; protected set; }
        public string Author { get; protected set; }
        public FormDisplayType DisplayType { get; protected set; }
        public bool VisibleLive { get; protected set; }
        public bool VisiblePreview { get; protected set; }
        public string CSS { get; protected set; }
        public bool ShowSummary { get; protected set; }
        public bool ShowAsSurvey { get; protected set; }
        public string EmailSubject { get; protected set; }
        public string EmailFrom { get; protected set; }
        public string ConfirmEmail { get; protected set; }
        public int Kickback { get; protected set; }
        public string ReturnUrl { get; protected set; }
        public string CompletedText { get; protected set; }
        public string PageCSS { get; protected set; }
        public string SelectedPageCSS { get; protected set; }
        public bool AnswerOnce { get; protected set; }

        protected List<FormPage> _pages = null;
        public List<FormPage> Pages
        {
            get
            {
                if (_pages == null)
                {
                    _pages = loadPages();
                }

                return _pages;
            }
        }

        #endregion

        #region Constructors

        internal Form()
        {
            this.ID = 0;
            this.CreationDate = DateTime.Now;
            this.LastModifiedDate = DateTime.Now;
            this.ApprobationDate = DateTime.Now;
            this.Status = FormStatus.New;
            this.DisplayType = FormDisplayType.LabelLeft;
            this.VisibleLive = false;
            this.VisiblePreview = false;
            this.ShowSummary = false;
            this.ShowAsSurvey = false;
            this.Kickback = 0;
            this.AnswerOnce = false;
        }

        public Form(int ID, string cultureCode) : this()
        {
            throw new NotImplementedException("Not implemented"); // TODO
        }

        #endregion

        #region Methods

        protected List<FormPage> loadPages()
        {
            throw new NotImplementedException("Not implemented"); // TODO
        }

        protected bool PageIsVisible(FormPage page)
        {
            return (CMServices.IsLive && page.VisibleLive) || (!CMServices.IsLive && page.VisiblePreview);
        }
        
        #endregion
    }
}
